<?php
class Deposit extends AppModel {

	var $name = 'Deposit';
	var $validate = array(
		'number' => array('notempty'),
		'amount' => array('notempty', 'numeric'),
		'date' => array('notempty','date'),
		'type' => array('notempty')
	);
	
	function beforeSave(){
		if (isset($this->data['Deposit']['number'])){
			$this->data['Deposit']['number'] = str_pad($this->data['Deposit']['number'], 11, "0", STR_PAD_LEFT);
		}
		return true;
	}
	/*
	var $hasMany = array(
		'DepositTournament' => array(
			'className' => 'DepositTournament',
			'foreignKey' => 'deposit_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
	);
	*/
	//The Associations below have been created with all possible keys, those that are not needed can be removed
	var $hasAndBelongsToMany = array(
			'Tournament' => array('className' => 'Tournament',
						'joinTable' => 'user_tournaments',
						'foreignKey' => 'deposit_id',
						'associationForeignKey' => 'tournament_id',
						'unique' => true,
						'conditions' => '',
						'fields' => '',
						'order' => '',
						'limit' => '',
						'offset' => '',
						'finderQuery' => '',
						'deleteQuery' => '',
						'insertQuery' => ''
			),
			'User' => array('className' => 'User',
						'joinTable' => 'user_tournaments',
						'foreignKey' => 'deposit_id',
						'associationForeignKey' => 'user_id',
						'unique' => true,
						'conditions' => '',
						'fields' => '',
						'order' => '',
						'limit' => '',
						'offset' => '',
						'finderQuery' => '',
						'deleteQuery' => '',
						'insertQuery' => ''
			)
	);

}
?>